﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace hostal
{
    public partial class BuscarCliente : Form
    {
        DataTable temp = new DataTable();
        public BuscarCliente()
        {
            InitializeComponent();
        }

        private void callFormsChild(Form form)
        {
            form.MdiParent = this.MdiParent;
            form.Show();
            this.Close();
        }

        private void BuscarCliente_Load(object sender, EventArgs e)
        {
            DGClientes.Columns.Clear();
            ClienteDataAccess hDal = new ClienteDataAccess();
            temp = hDal.buscarClientes();
            DGClientes.DataSource = temp; 
        }

        private void button16_Click(object sender, EventArgs e)
        {
            try
            {
                int fila = DGClientes.CurrentRow.Index;
                if (fila != -1)
                {
                    VerCliente m = new VerCliente(DGClientes.Rows[fila].Cells[0].Value.ToString());
                    m.ShowDialog();
                    //callFormsChild(m);
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DGClientes.Columns.Clear();
            ClienteDataAccess hDal = new ClienteDataAccess();
            temp = hDal.buscarDatosLimitado(TBBuscar.Text.ToLowerInvariant());
            DGClientes.DataSource = temp;
        }

        private void button17_Click(object sender, EventArgs e)
        {
            try
            {
                int fila = DGClientes.CurrentRow.Index;
                if (fila != -1)
                {
                    ModificarCliente m = new ModificarCliente(DGClientes.Rows[fila].Cells[0].Value.ToString());
                    callFormsChild(m);
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
